package advanced.practice._1003;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String...args){
        Scanner scanner=new Scanner(System.in);

        int N=scanner.nextInt();

        List<Student> students=new ArrayList<>();
        for(int i=0;i<N;i++){
            Student student=new Student(scanner.next(),scanner.next(),scanner.nextInt());
            students.add(student);
        }

        int MIN_SCORE=scanner.nextInt();
        int MAX_SCORE=scanner.nextInt();

        students.sort(new Comparator<Student>() {
            @Override
            public int compare(Student o1, Student o2) {
                return o2.score-o1.score;
            }
        });

        boolean noOutput=true;
        for(int i=0;i<N;i++){
            Student student=students.get(i);
           if(student.score>=MIN_SCORE&&student.score<=MAX_SCORE){
               System.out.println(student.name+" "+student.course);
               noOutput=false;
           }
        }
        if(noOutput){
            System.out.println("NONE");
        }
    }

    static class Student {
        String name;
        String course;
        int score;

        Student(String name, String course, int score){
            this.name=name;
            this.course =course;
            this.score=score;
        }
    }
}
